/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kayit;

import java.io.IOException;
import javax.media.CannotRealizeException;
import javax.media.DataSink;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoDataSinkException;
import javax.media.NoProcessorException;
import javax.media.Processor;
import javax.media.ProcessorModel;
import javax.media.format.VideoFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.FileTypeDescriptor;
/**
 *
 * @author Semih Altınsoy
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
Format formats[] = new Format[1];
formats[0] = new VideoFormat(VideoFormat.CINEPAK);
FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.QUICKTIME);
Processor p = null;
try {
p = Manager.createRealizedProcessor(new ProcessorModel(formats,outputType));
} catch (IOException e) {
System.exit(-1);
} catch (NoProcessorException e) {
System.exit(-1);
} catch (CannotRealizeException e) {
System.exit(-1);
}
// get the output of the processor
DataSource source = p.getDataOutput();
// create a File protocol MediaLocator with the location
// of the file to
// which bits are to be written
MediaLocator dest = new MediaLocator("file://dosya.avi");
// create a datasink to do the file writing & open the
// sink to make sure
// we can write to it.
DataSink filewriter = null;
try {
filewriter = Manager.createDataSink(source, dest);
filewriter.open();
} catch (NoDataSinkException e) {
System.exit(-1);
} catch (IOException e) {
System.exit(-1);
} catch (SecurityException e) {
System.exit(-1);
}
// now start the filewriter and processor
try {
filewriter.start();
} catch (IOException e) {
System.exit(-1);
}
p.start();
try {       Thread.sleep(10000); } catch (InterruptedException ie) {}
p.stop();
p.close();
filewriter.close();
// stop and close the processor when done capturing...
// close the datasink when EndOfStream event is received...
    }

}
